package com.qianbei.user.income;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qianbei.R;
import com.qianbei.common.utilis.DateUtil;

import java.util.List;


/**
 * 作者:GaoQian on 2016/10/29.
 * 邮箱:gaoqian_zz@163.com
 */

public class MoneyAdapter extends android.widget.BaseAdapter {
    Context context;
    List<IncomeBean.DataBean.MoneylistBean> moneyList;


    public MoneyAdapter(Context context, List<IncomeBean.DataBean.MoneylistBean> moneyList) {
        this.context = context;
        this.moneyList = moneyList;

    }

    @Override
    public int getCount() {

        return moneyList.size();

    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.kh_income_item, null);
            viewHolder = new ViewHolder();
//            viewHolder.mItemIncomeInfo = (TextView) convertView.findViewById(R.id.item_income_info);
//            viewHolder.mItemIncomeMoney = (TextView) convertView.findViewById(R.id.item_income_money);
//            viewHolder.mItemIncomeTime = (TextView) convertView.findViewById(R.id.item_income_time);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.mItemIncomeInfo.setText(moneyList.get(position).getInfo());
        viewHolder.mItemIncomeMoney.setText(moneyList.get(position).getShu());
        String dateStrToString = DateUtil.timeStamp2Date(String.valueOf(moneyList.get(position).getAddtime()), "");

        viewHolder.mItemIncomeTime.setText(dateStrToString);


        return convertView;
    }


    class ViewHolder {
        TextView mItemIncomeInfo;
        TextView mItemIncomeMoney;
        TextView mItemIncomeTime;

    }

}
